From 5930ad5af110fbbc28b08e89114698e918036c04 Mon Sep 17 00:00:00 2001 From: john Date: Sun, 14 May 2023 10:19:04 -0400 Subject: [PATCH] Additional changes to move application to CouchDB database backend. Removed loan files from repository (now in selfhosted couchdb instance). --- 0_Test_Loan.loan | 102 ------- 1_Dad_Mortgage.loan | 328 ---------------------- 2_Brenda_Mortgage.loan | 328 ---------------------- 3_839_Harbor_Bend_2022.loan | 92 ------ Dockerfile | 4 +- _Archive_Greenfield_Lane_Mortgage.loan | 255 ----------------- _Archive_Greenfield_Lane_Refinance-1.loan | 128 --------- _Archive_Old_Harbor_Bend_Mortgage.loan | 50 ---- _Archive_Wayneland_Mortgage.loan | 137 --------- mortgage/templates/add.html | 2 +- mortgage/templates/email.html | 2 +- mortgage/templates/main.html | 16 +- mortgage/web.py | 108 +++---- 13 files changed, 49 insertions(+), 1503 deletions(-) delete mode 100644 0_Test_Loan.loan delete mode 100644 1_Dad_Mortgage.loan delete mode 100644 2_Brenda_Mortgage.loan delete mode 100644 3_839_Harbor_Bend_2022.loan delete mode 100644 _Archive_Greenfield_Lane_Mortgage.loan delete mode 100644 _Archive_Greenfield_Lane_Refinance-1.loan delete mode 100644 _Archive_Old_Harbor_Bend_Mortgage.loan delete mode 100644 _Archive_Wayneland_Mortgage.loan diff --git a/0_Test_Loan.loan b/0_Test_Loan.loan deleted file mode 100644 index e8faba3..0000000 --- a/0_Test_Loan.loan +++ /dev/null @@ -1,102 +0,0 @@ -{ - "parameters": { - "monthly_payment": 589.0, - "interest_rate": 6.5, - "start_interest_date": "2017-12-05", - "payment_day_of_month": "15", - "first_payment_month": "2018-01-15", - "account_number": "100100", - "principal": 10020.0, - "start_date": "2017-12-05", - "periods_per_year": 12, - "periods": 18 - }, - "lender": { - "city": "Washington", - "name": "Test Lender", - "zip": "20011", - "phone": "703.343.0782", - "state": "DC", - "address": "743 Madison St NW" - }, - "header": { - "date": "Today", - "title": "Installment Loan Test Statement" - }, - "payments": [ - [ - "2019-07-15", - "475.00" - ], - [ - "2019-08-14", - "475.00" - ], - [ - "2019-09-17", - "475" - ], - [ - "2019-10-15", - "0" - ], - [ - "2019-11-15", - "0" - ], - [ - "2019-12-5", - "475" - ], - [ - "2020-01-15", - "0", - "50" - ], - [ - "2020-09-27", - "278.15", - "20" - ], - [ - "2020-09-29", - "296.12", - "25" - ], - [ - "2020-10-16", - "133", - "0.00" - ], - [ - "2020-10-16", - "133", - "0.00" - ], - [ - "2020-10-16", - "133", - "0.00" - ], - [ - "2021-05-03", - "1", - "1" - ] - ], - "borrower": { - "city": "Alexandria", - "state": "VA", - "name": "Test Borrower Houses, LLC", - "zip": "22312", - "address": "301 N Beauregard St Apt 203" - }, - "email": { - "to_address": "jkent3rd@gmail.com", - "from_address": "jkent3rd@gmail.com", - "subject": "Your test loan statement...", - "body": "Your test loan statement is attached.", - "server": "smtp.gmail.com", - "password": "builcuouzobxroow" - } -} \ No newline at end of file diff --git a/1_Dad_Mortgage.loan b/1_Dad_Mortgage.loan deleted file mode 100644 index 15f9453..0000000 --- a/1_Dad_Mortgage.loan +++ /dev/null @@ -1,328 +0,0 @@ -{ - "htmlTemplate": "statement.pdf.jinja", - "parameters": { - "monthly_payment": 278.15, - "interest_rate": 5.0, - "start_interest_date": "2018-07-01", - "payment_day_of_month": "01", - "first_payment_month": "2018-08-01", - "account_number": "100001", - "periods": 180, - "start_date": "2018-06-25", - "periods_per_year": 12, - "principal": 35000.0 - }, - "format": "html", - "email": { - "body": "Your loan statement is attached.", - "to_address": "johnakent722@gmail.com", - "from_address": "jkent3rd@gmail.com", - "text": "Please see your most recent account statement.", - "server": "smtp.gmail.com", - "send_text": "true", - "template": "./template.txt", - "send_pdf": "true", - "password": "builcuouzobxroow", - "subject": "Your loan statement..." - }, - "lender": { - "city": "Palmyra", - "name": "John Kent", - "zip": "22963", - "phone": "434-510-7272", - "state": "VA", - "address": "109 Shores Rd" - }, - "header": { - "date": "Today", - "title": "Mortgage Loan Statement - 185 James River Rd, Scottsville VA" - }, - "payments": [ - [ - "2018-08-01", - "278.15" - ], - [ - "2018-09-01", - "278.15" - ], - [ - "2018-10-01", - "278.15" - ], - [ - "2018-11-01", - "278.15" - ], - [ - "2018-12-01", - "278.15" - ], - [ - "2019-01-01", - "278.15" - ], - [ - "2019-02-01", - "278.15" - ], - [ - "2019-03-01", - "278.15" - ], - [ - "2019-04-01", - "278.15" - ], - [ - "2019-05-01", - "278.15" - ], - [ - "2019-05-31", - "278.15" - ], - [ - "2019-07-01", - "278.15" - ], - [ - "2019-08-01", - "278.15" - ], - [ - "2019-09-02", - "278.15" - ], - [ - "2019-10-01", - "278.15" - ], - [ - "2019-11-01", - "278.15" - ], - [ - "2019-12-02", - "278.15" - ], - [ - "2020-01-02", - "278.15" - ], - [ - "2020-02-01", - "278.15" - ], - [ - "2020-03-02", - "278.15" - ], - [ - "2020-04-01", - "278.15" - ], - [ - "2020-05-01", - "278.15" - ], - [ - "2020-06-01", - "278.15" - ], - [ - "2020-07-01", - "278.15" - ], - [ - "2020-08-01", - "278.15" - ], - [ - "2020-09-01", - "278.15" - ], - [ - "2020-10-01", - "278.15" - ], - [ - "2020-11-01", - "278.15", - "0.00" - ], - [ - "2020-12-01", - "278.15", - "0.00" - ], - [ - "2021-01-01", - "278.15", - "0" - ], - [ - "2021-02-01", - "278.15", - "0" - ], - [ - "2021-03-01", - "278.15", - "0.00" - ], - [ - "2021-04-01", - "278.15", - "0.00" - ], - [ - "2021-04-30", - "278.15", - "0" - ], - [ - "2021-06-01", - "278.15", - "0.00" - ], - [ - "2021-07-01", - "278.15", - "0" - ], - [ - "2021-07-31", - "278.15", - "0" - ], - [ - "2021-09-01", - "278.15", - "0.00", - "False" - ], - [ - "2021-10-01", - "278.15", - "0.00", - "False" - ], - [ - "2021-11-01", - "278.15", - "0", - "False" - ], - [ - "2021-12-01", - "278.15", - "0.00", - "False" - ], - [ - "2022-01-01", - "278.15", - "0.00", - "False" - ], - [ - "2022-02-01", - "278.15", - "0.00", - "False" - ], - [ - "2022-03-01", - "278.15", - "0.00", - "False" - ], - [ - "2022-04-01", - "278.15", - "0.00", - "False" - ], - [ - "2022-05-01", - "278.15", - "0.00", - "False" - ], - [ - "2022-06-01", - "278.15", - "0.00", - "False" - ], - [ - "2022-07-01", - "278.15", - "0.00", - "False" - ], - [ - "2022-08-01", - "278.15", - "0.00", - "False" - ], - [ - "2022-09-01", - "278.15", - "0.00", - "False" - ], - [ - "2022-10-01", - "278.15", - "0.00", - "False" - ], - [ - "2022-10-31", - "278.15", - "0.00", - "False" - ], - [ - "2022-12-01", - "278.15", - "0.00", - "False" - ], - [ - "2023-01-03", - "278.15", - "0.00", - "False" - ], - [ - "2023-02-01", - "278.15", - "0.00", - "False" - ], - [ - "2023-03-01", - "278.15", - "0.00", - "False" - ], - [ - "2023-04-01", - "278.15", - "0.00", - "False" - ] - ], - "borrower": { - "city": "Washington", - "state": "DC", - "name": "Grandma Tina's Properties, LLC", - "zip": "20001", - "address": "1720 New Jersey Ave NW Unit 401" - }, - "txtTemplate": "statement.txt.jinja" -} \ No newline at end of file diff --git a/2_Brenda_Mortgage.loan b/2_Brenda_Mortgage.loan deleted file mode 100644 index 00912f2..0000000 --- a/2_Brenda_Mortgage.loan +++ /dev/null @@ -1,328 +0,0 @@ -{ - "htmlTemplate": "statement.pdf.jinja", - "parameters": { - "monthly_payment": 278.15, - "interest_rate": 5.0, - "start_interest_date": "2018-07-01", - "payment_day_of_month": "01", - "first_payment_month": "2018-08-01", - "account_number": "100001", - "periods": 180, - "start_date": "2018-06-25", - "periods_per_year": 12, - "principal": 35000.0 - }, - "format": "html", - "email": { - "body": "Your loan statement is attached.", - "to_address": "bck@virginia.edu", - "from_address": "jkent3rd@gmail.com", - "text": "Please see your most recent account statement.", - "server": "smtp.gmail.com", - "send_text": "true", - "template": "./template.txt", - "send_pdf": "true", - "password": "builcuouzobxroow", - "subject": "Your loan statement..." - }, - "lender": { - "city": "Scottsville", - "name": "Brenda Kelly", - "zip": "24590", - "phone": "434-286-2110", - "state": "VA", - "address": "150 Confederate Street" - }, - "header": { - "date": "Today", - "title": "Mortgage Loan Statement - 185 James River Rd, Scottsville VA" - }, - "payments": [ - [ - "2018-08-01", - "278.15" - ], - [ - "2018-09-01", - "278.15" - ], - [ - "2018-10-01", - "278.15" - ], - [ - "2018-11-01", - "278.15" - ], - [ - "2018-12-01", - "278.15" - ], - [ - "2019-01-01", - "278.15" - ], - [ - "2019-02-01", - "278.15" - ], - [ - "2019-03-01", - "278.15" - ], - [ - "2019-04-01", - "278.15" - ], - [ - "2019-05-01", - "278.15" - ], - [ - "2019-05-31", - "278.15" - ], - [ - "2019-07-01", - "278.15" - ], - [ - "2019-08-01", - "278.15" - ], - [ - "2019-09-02", - "278.15" - ], - [ - "2019-10-01", - "278.15" - ], - [ - "2019-11-01", - "278.15" - ], - [ - "2019-12-02", - "278.15" - ], - [ - "2020-01-02", - "278.15" - ], - [ - "2020-02-01", - "278.15" - ], - [ - "2020-03-01", - "278.15" - ], - [ - "2020-04-01", - "278.15" - ], - [ - "2020-05-01", - "278.15" - ], - [ - "2020-06-01", - "278.15" - ], - [ - "2020-07-01", - "278.15" - ], - [ - "2020-08-01", - "278.15" - ], - [ - "2020-09-01", - "278.15" - ], - [ - "2020-10-01", - "278.15" - ], - [ - "2020-11-01", - "278.15", - "0.00" - ], - [ - "2020-12-01", - "278.15", - "0.00" - ], - [ - "2021-01-01", - "278.15", - "0" - ], - [ - "2021-02-01", - "278.15", - "0" - ], - [ - "2021-03-01", - "278.15", - "0.00" - ], - [ - "2021-04-01", - "278.15", - "0.00" - ], - [ - "2021-04-30", - "278.15", - "0" - ], - [ - "2021-06-01", - "278.15", - "0.00" - ], - [ - "2021-07-01", - "278.15", - "0" - ], - [ - "2021-07-31", - "278.15", - "0" - ], - [ - "2021-09-01", - "278.15", - "0.00", - "False" - ], - [ - "2021-10-01", - "278.15", - "0.00", - "False" - ], - [ - "2021-11-01", - "278.15", - "0", - "False" - ], - [ - "2021-12-01", - "278.15", - "0.00", - "False" - ], - [ - "2022-01-01", - "278.15", - "0.00", - "False" - ], - [ - "2022-02-01", - "278.15", - "0", - "False" - ], - [ - "2022-03-01", - "278.15", - "0.00", - "False" - ], - [ - "2022-04-01", - "278.15", - "0.00", - "False" - ], - [ - "2022-05-01", - "278.15", - "0.00", - "False" - ], - [ - "2022-06-01", - "278.15", - "0.00", - "False" - ], - [ - "2022-07-01", - "278.15", - "0.00", - "False" - ], - [ - "2022-08-01", - "278.15", - "0.00", - "False" - ], - [ - "2022-09-01", - "278.15", - "0.00", - "False" - ], - [ - "2022-10-01", - "278.15", - "0.00", - "False" - ], - [ - "2022-10-31", - "278.15", - "0.00", - "False" - ], - [ - "2022-12-01", - "278.15", - "0.00", - "False" - ], - [ - "2023-01-03", - "278.15", - "0.00", - "False" - ], - [ - "2023-02-01", - "278.15", - "0.00", - "False" - ], - [ - "2023-03-01", - "278.15", - "0.00", - "False" - ], - [ - "2023-04-01", - "278.15", - "0.00", - "False" - ] - ], - "borrower": { - "city": "Washington", - "state": "DC", - "name": "Grandma Tina's Properties, LLC", - "zip": "20001", - "address": "1720 New Jersey Ave NW Unit 401" - }, - "txtTemplate": "statement.txt.jinja" -} \ No newline at end of file diff --git a/3_839_Harbor_Bend_2022.loan b/3_839_Harbor_Bend_2022.loan deleted file mode 100644 index 3fa68d7..0000000 --- a/3_839_Harbor_Bend_2022.loan +++ /dev/null @@ -1,92 +0,0 @@ -{ - "htmlTemplate": "statement.pdf.jinja", - "parameters": { - "monthly_payment": 842.93, - "interest_rate": 5.75, - "start_interest_date": "2022-08-12", - "payment_day_of_month": "15", - "first_payment_month": "2022-09-15", - "account_number": "22-0001", - "periods": 180, - "start_date": "2022-08-12", - "periods_per_year": 12, - "principal": 101508.04 - }, - "format": "html", - "email": { - "body": "Your loan statement is attached.", - "to_address": "grady@gradystreet.com", - "from_address": "jkent3rd@gmail.com", - "text": "Please see your most recent account statement.", - "server": "smtp.gmail.com", - "send_text": "true", - "template": "./template.txt", - "send_pdf": "true", - "password": "builcuouzobxroow", - "subject": "Your loan statement..." - }, - "lender": { - "city": "Washington", - "name": "Rivanna Graphite Investments, LLC", - "zip": "20001", - "phone": "703.343.0782", - "state": "DC", - "address": "1720 New Jersey Ave NW Unit 401" - }, - "header": { - "date": "Today", - "title": "Mortgage Loan Statement - Harbor Bend Loan 1" - }, - "payments": [ - [ - "2022-08-15", - "803", - "0", - "False" - ], - [ - "2022-09-09", - "803", - "0.00", - "False" - ], - [ - "2022-11-17", - "842.93", - "0.00", - "False" - ], - [ - "2022-12-29", - "842.93", - "0.00", - "False" - ], - [ - "2023-01-27", - "842.93", - "0.00", - "False" - ], - [ - "2023-02-10", - "842.93", - "0.00", - "False" - ], - [ - "2023-03-31", - "0", - "33.68", - "False" - ] - ], - "borrower": { - "city": "Alexandria", - "state": "VA", - "name": "Bear Houses, LLC", - "zip": "22312", - "address": "301 N Beauregard St Apt 203" - }, - "txtTemplate": "statement.txt.jinja" -} \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 336d66a..0c6ffa6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,6 +3,6 @@ FROM python:3.8-slim-buster COPY requirements.txt requirements.txt RUN pip3 install -r requirements.txt -COPY . . +COPY mortgage/ . -CMD [ "python3", "-m" , "flask", "run", "--host=0.0.0.0"] \ No newline at end of file +CMD [ "python3", "-m" , "web", "run", "--host=0.0.0.0"] \ No newline at end of file diff --git a/_Archive_Greenfield_Lane_Mortgage.loan b/_Archive_Greenfield_Lane_Mortgage.loan deleted file mode 100644 index 22fe53d..0000000 --- a/_Archive_Greenfield_Lane_Mortgage.loan +++ /dev/null @@ -1,255 +0,0 @@ -{ - "htmlTemplate": "statement.pdf.jinja", - "parameters": { - "monthly_payment": 803.0, - "interest_rate": 5.5, - "start_interest_date": "2017-11-11", - "payment_day_of_month": "15", - "first_payment_month": "2017-12-15", - "account_number": "100001", - "periods": 185, - "start_date": "2017-11-07", - "periods_per_year": 12, - "principal": 97750.0 - }, - "format": "html", - "email": { - "body": "Your loan statement is attached.", - "to_address": "grady@gradystreet.com", - "from_address": "jkent3rd@gmail.com", - "text": "Please see your most recent account statement.", - "server": "smtp.gmail.com", - "send_text": "true", - "template": "./template.txt", - "send_pdf": "true", - "password": "builcuouzobxroow", - "subject": "Your loan statement..." - }, - "lender": { - "city": "Washington", - "name": "Rivanna Graphite Investments, LLC", - "zip": "20001", - "phone": "703.343.0782", - "state": "DC", - "address": "1720 New Jersey Ave NW Unit 401" - }, - "header": { - "date": "Today", - "title": "Mortgage Loan Statement - 195 Greenfield Lane, Pearl MS" - }, - "payments": [ - [ - "2017-12-11", - "803.00" - ], - [ - "2018-01-23", - "803.00" - ], - [ - "2018-03-23", - "803.00" - ], - [ - "2018-04-18", - "803.00" - ], - [ - "2018-04-26", - "803.00" - ], - [ - "2018-05-15", - "0.00" - ], - [ - "2018-06-15", - "0.00" - ], - [ - "2018-07-12", - "803.00" - ], - [ - "2018-08-07", - "803.00" - ], - [ - "2018-09-06", - "803.00" - ], - [ - "2018-10-11", - "803.00" - ], - [ - "2018-11-13", - "803.00" - ], - [ - "2018-12-13", - "803.00" - ], - [ - "2019-01-14", - "803.00" - ], - [ - "2019-02-05", - "803.00" - ], - [ - "2019-03-05", - "803.00" - ], - [ - "2019-04-15", - "803.00" - ], - [ - "2019-05-15", - "0.00" - ], - [ - "2019-06-13", - "803.00" - ], - [ - "2019-07-25", - "803.00" - ], - [ - "2019-08-14", - "803.00" - ], - [ - "2019-09-13", - "803.00" - ], - [ - "2019-10-21", - "803.00" - ], - [ - "2019-11-29", - "803.00" - ], - [ - "2019-12-19", - "803.00" - ], - [ - "2020-01-15", - "803" - ], - [ - "2020-03-06", - "803", - "32.12" - ], - [ - "2020-03-13", - "803.00" - ], - [ - "2020-04-15", - "803.00" - ], - [ - "2020-05-13", - "803.00" - ], - [ - "2020-06-16", - "803.00" - ], - [ - "2020-07-15", - "803" - ], - [ - "2020-08-13", - "803" - ], - [ - "2020-09-17", - "803" - ], - [ - "2020-10-15", - "803", - "0.00" - ], - [ - "2020-11-16", - "803.00", - "0" - ], - [ - "2020-12-15", - "803.00", - "0.00" - ], - [ - "2021-01-13", - "803.00", - "0" - ], - [ - "2021-02-16", - "803.00", - "0" - ], - [ - "2021-03-22", - "0", - "32.12" - ], - [ - "2021-04-14", - "803.00", - "0.00" - ], - [ - "2021-05-18", - "803.00", - "0" - ], - [ - "2021-06-15", - "803.00", - "0" - ], - [ - "2021-07-31", - "0", - "32.12" - ], - [ - "2021-08-18", - "803", - "0.00", - "False" - ], - [ - "2021-09-24", - "803", - "0.00", - "False" - ], - [ - "2021-09-25", - "0", - "0.00", - "False" - ] - ], - "borrower": { - "city": "Alexandria", - "state": "VA", - "name": "Bear Houses, LLC", - "zip": "22312", - "address": "301 N Beauregard St Apt 203" - }, - "txtTemplate": "statement.txt.jinja" -} \ No newline at end of file diff --git a/_Archive_Greenfield_Lane_Refinance-1.loan b/_Archive_Greenfield_Lane_Refinance-1.loan deleted file mode 100644 index 5ab8f08..0000000 --- a/_Archive_Greenfield_Lane_Refinance-1.loan +++ /dev/null @@ -1,128 +0,0 @@ -{ - "htmlTemplate": "statement.pdf.jinja", - "parameters": { - "monthly_payment": 831.0, - "interest_rate": 5.5, - "start_interest_date": "2021-10-13", - "payment_day_of_month": "15", - "first_payment_month": "2021-11-15", - "account_number": "21-0004", - "periods": 180, - "start_date": "2021-10-13", - "periods_per_year": 12, - "principal": 101123.26 - }, - "format": "html", - "email": { - "body": "Your loan statement is attached.", - "to_address": "grady@gradystreet.com", - "from_address": "jkent3rd@gmail.com", - "text": "Please see your most recent account statement.", - "server": "smtp.gmail.com", - "send_text": "true", - "template": "./template.txt", - "send_pdf": "true", - "password": "builcuouzobxroow", - "subject": "Your loan statement..." - }, - "lender": { - "city": "Washington", - "name": "Rivanna Graphite Investments, LLC", - "zip": "20001", - "phone": "703.343.0782", - "state": "DC", - "address": "1720 New Jersey Ave NW Unit 401" - }, - "header": { - "date": "Today", - "title": "Mortgage Loan Statement - 195 Greenfield Lane, Pearl MS" - }, - "payments": [ - [ - "2021-10-14", - "803", - "0.00", - "False" - ], - [ - "2021-10-14", - "28", - "0.00", - "False" - ], - [ - "2021-10-18", - "28", - "0.00", - "False" - ], - [ - "2021-11-16", - "803.00", - "0.00", - "False" - ], - [ - "2021-11-19", - "28", - "0.00", - "False" - ], - [ - "2022-02-10", - "831", - "0.00", - "False" - ], - [ - "2022-04-04", - "1000", - "55.00", - "False" - ], - [ - "2022-05-15", - "0", - "0.00", - "False" - ], - [ - "2022-06-15", - "0", - "0.00", - "False" - ], - [ - "2022-07-15", - "0", - "0.00", - "False" - ], - [ - "2022-07-26", - "803", - "0.00", - "False" - ], - [ - "2022-08-12", - "0", - "0.00", - "False" - ], - [ - "2022-08-12", - "101508.04", - "0.00", - "False" - ] - ], - "borrower": { - "city": "Alexandria", - "state": "VA", - "name": "Bear Houses, LLC", - "zip": "22312", - "address": "301 N Beauregard St Apt 203" - }, - "txtTemplate": "statement.txt.jinja" -} \ No newline at end of file diff --git a/_Archive_Old_Harbor_Bend_Mortgage.loan b/_Archive_Old_Harbor_Bend_Mortgage.loan deleted file mode 100644 index c89078d..0000000 --- a/_Archive_Old_Harbor_Bend_Mortgage.loan +++ /dev/null @@ -1,50 +0,0 @@ -{ - "htmlTemplate": "statement.pdf.jinja", - "parameters": { - "monthly_payment": 848, - "interest_rate": 5.75, - "start_interest_date": "2022-08-12", - "payment_day_of_month": "15", - "first_payment_month": "2022-09-15", - "account_number": "22-0001", - "periods": 180, - "start_date": "2022-08-12", - "periods_per_year": 12, - "principal": 101508.04 - }, - "format": "html", - "email": { - "body": "Your loan statement is attached.", - "to_address": "grady@gradystreet.com", - "from_address": "jkent3rd@gmail.com", - "text": "Please see your most recent account statement.", - "server": "smtp.gmail.com", - "send_text": "true", - "template": "./template.txt", - "send_pdf": "true", - "password": "builcuouzobxroow", - "subject": "Your loan statement..." - }, - "lender": { - "city": "Washington", - "name": "Rivanna Graphite Investments, LLC", - "zip": "20001", - "phone": "703.343.0782", - "state": "DC", - "address": "1720 New Jersey Ave NW Unit 401" - }, - "header": { - "date": "Today", - "title": "Mortgage Loan Statement - Harbor Bend Loan 1" - }, - "payments": [ - ], - "borrower": { - "city": "Alexandria", - "state": "VA", - "name": "Bear Houses, LLC", - "zip": "22312", - "address": "301 N Beauregard St Apt 203" - }, - "txtTemplate": "statement.txt.jinja" -} \ No newline at end of file diff --git a/_Archive_Wayneland_Mortgage.loan b/_Archive_Wayneland_Mortgage.loan deleted file mode 100644 index f7cde9e..0000000 --- a/_Archive_Wayneland_Mortgage.loan +++ /dev/null @@ -1,137 +0,0 @@ -{ - "htmlTemplate": "statement.pdf.jinja", - "parameters": { - "monthly_payment": 175.55, - "interest_rate": 4.5, - "start_interest_date": "2020-07-15", - "payment_day_of_month": "15", - "first_payment_month": "2020-08-15", - "account_number": "100003", - "periods": 60, - "start_date": "2020-07-15", - "periods_per_year": 12, - "principal": 16884 - }, - "format": "html", - "email": { - "body": "Your loan statement is attached.", - "to_address": "grady@gradystreet.com", - "from_address": "jkent3rd@gmail.com", - "text": "Please see your most recent account statement.", - "server": "smtp.gmail.com", - "send_text": "true", - "template": "./template.txt", - "send_pdf": "true", - "password": "builcuouzobxroow", - "subject": "Your loan statement..." - }, - "lender": { - "city": "Washington", - "name": "Rivanna Graphite Investments, LLC", - "zip": "20008", - "phone": "703.343.0782", - "state": "DC", - "address": "3100 Connecticut Ave NW Apt 144" - }, - "header": { - "date": "Today", - "title": "Mortgage Loan Statement - 5025 Wayneland Drive Apt D11 Jackson MS 39211" - }, - "payments": [ - [ - "2020-08-27", - "175.55" - ], - [ - "2020-09-30", - "175.55" - ], - [ - "2020-10-19", - "175.55", - "0.00" - ], - [ - "2020-12-01", - "0", - "17.55" - ], - [ - "2020-12-29", - "0", - "17.55" - ], - [ - "2021-01-20", - "175.55", - "0" - ], - [ - "2021-02-15", - "0.00", - "17.55" - ], - [ - "2021-03-12", - "175.55", - "0.00" - ], - [ - "2021-04-15", - "0", - "17.55" - ], - [ - "2021-05-17", - "0", - "17.55" - ], - [ - "2021-06-30", - "0", - "0.00" - ], - [ - "2021-07-29", - "175.55", - "17.55" - ], - [ - "2021-08-09", - "175.55", - "0" - ], - [ - "2021-08-10", - "175.55", - "0", - "extra" - ], - [ - "2021-09-03", - "175.55", - "0.00", - "False" - ], - [ - "2021-09-17", - "175.55", - "0.00", - "False" - ], - [ - "2021-09-18", - "0", - "0.00", - "False" - ] - ], - "borrower": { - "city": "Alexandria", - "state": "VA", - "name": "Bear Houses, LLC", - "zip": "22312", - "address": "301 N Beauregard St Apt 203" - }, - "txtTemplate": "statement.txt.jinja" -} \ No newline at end of file diff --git a/mortgage/templates/add.html b/mortgage/templates/add.html index 78323fd..a797f44 100644 --- a/mortgage/templates/add.html +++ b/mortgage/templates/add.html @@ -17,6 +17,6 @@ {{message}} {% endfor %} -Return to Main Screen. +Return to Main Screen. \ No newline at end of file diff --git a/mortgage/templates/email.html b/mortgage/templates/email.html index 530e273..609fde3 100644 --- a/mortgage/templates/email.html +++ b/mortgage/templates/email.html @@ -13,7 +13,7 @@

The email has been sent.

-Return to Main Screen. +Return to Main Screen. \ No newline at end of file diff --git a/mortgage/templates/main.html b/mortgage/templates/main.html index 29e8664..2315490 100644 --- a/mortgage/templates/main.html +++ b/mortgage/templates/main.html @@ -16,10 +16,10 @@ @@ -44,8 +44,8 @@
  • Loan History
  • Future Amortization
  • Email Statement
  • -
  • Add Payment
  • -
  • Add Payment
  • +
  • Add a Regular Payment
  • +
  • Add an Extra Payment
  • @@ -163,12 +163,12 @@
    - +
    - + @@ -184,7 +184,7 @@
    - +
    Record a Payment
    Payment Date:
    diff --git a/mortgage/web.py b/mortgage/web.py index b3a16f8..676e5a3 100644 --- a/mortgage/web.py +++ b/mortgage/web.py @@ -10,9 +10,12 @@ from email.mime.multipart import MIMEMultipart from email.mime.text import MIMEText from email.mime.base import MIMEBase from email import encoders +import couchdb + +couch = couchdb.Server('https://admin:ams19230@couch.jkent.org:443/') +database = couch['mortgage'] module_directory = os.path.dirname(__file__) -app_directory = os.path.normpath(os.path.join(module_directory, "..")) loader = jinja2.FileSystemLoader([os.path.join(module_directory, "templates")]) environment = jinja2.Environment(loader=loader) app = Flask(__name__) @@ -24,31 +27,31 @@ app = Flask(__name__) @app.route('/') def hello(): - loans = getLoanFiles(app_directory) + loans = getLoanFiles(database) #if a loan was not specified, choose the first loan and reload page with it if 'loan' in request.args: - filename = request.args["loan"] + document_id = request.args["loan"] else: - return redirect('/?loan=' + loans[0]['filename']) + return redirect('/?loan=' + loans[0]['document_id']) - loan = loadLoanInformation(getFullPathOfLoanFile(filename)) + loan = loadLoanInformation(document_id) amortizeLoan(loan) - return render_template('main.html', filename=filename, loans=loans, model=loan) + return render_template('main.html', document_id=document_id, loans=loans, model=loan) @app.route('/update_file', methods=['POST']) def update_file(): messages = [] - loanFile = request.form["loan"] - data = getDatastore(getFullPathOfLoanFile(loanFile)) + document_id = request.form["loan"] + document = getDatastore(document_id) late_fee = Decimal('0.00').quantize(Decimal('1.00')) extra_payment = False payment_amount = Decimal('0.00').quantize(Decimal('1.00')) - payment_history = data["payments"] + payment_history = document["payments"] todays_date = str(datetime.now().strftime("%Y-%m-%d")) if 'date' in request.form: if request.form['date'] == '': @@ -88,44 +91,25 @@ def update_file(): extra_payment = True if proceed_flag is True: - try: - backup_filename = loanFile + ".backup-" + datetime.now().strftime("%Y-%m-%d %H-%M-%S") + ".json" - backup_file = open(getFullPathOfLoanFile(backup_filename), 'w+') - json.dump(data, backup_file, indent=2) - backup_file.close() - except: - messages.append("A backup file could not be created. Your payment was not recorded.") - proceed_flag = False - else: - messages.append("A backup of your file was created: '" + backup_filename + "'") - - if proceed_flag is True: - try: - payment_history.append([payment_date, str(payment_amount), str(late_fee), str(extra_payment)]) - file = open(getFullPathOfLoanFile(loanFile), 'w+') - json.dump(data, file, indent=2) - file.close() - except: - messages.append("An error occurred writing to the file. Your payment file may be corrupt, " + - "please consider rolling back to the backup created above.") - else: - messages.append("The payment was successfully written. ") + payment_history.append([payment_date, str(payment_amount), str(late_fee), str(extra_payment)]) + database[document_id]=document + messages.append("The payment was successfully written. ") # see if an email notification was requested, if not, exit now if 'notify' not in request.form: messages.append("Payment notification email not requested.") - return render_template('add.html', filename=loanFile, messages=messages) + return render_template('add.html', document_id=document_id, messages=messages) messages.append("Payment notification email requested.") # send email - emailParameters = data["email"] + emailParameters = document["email"] result = {} payment = {} result['payment'] = payment payment['today'] = todays_date payment['date'] = payment_date - payment['payer'] = data['borrower']['name'] - payment['payee'] = data['lender']['name'] + payment['payer'] = document['borrower']['name'] + payment['payee'] = document['lender']['name'] payment['amount'] = payment_amount payment['late_fee'] = late_fee payment['extra_payment'] = extra_payment @@ -135,16 +119,16 @@ def update_file(): msg = generatePaymentNotificationEmail(emailParameters["from_address"], emailParameters["to_address"], subject, html) sendEmail(msg, emailParameters["from_address"], emailParameters["to_address"], emailParameters['password']) - return render_template('add.html', filename=loanFile, messages=messages) + return render_template('add.html', document_id=document_id, messages=messages) @app.route('/send_statement', methods=['POST']) def send_statement(): - loanFile = request.form["loan"] + document_id = request.form["loan"] subject = request.form["subject"] message = request.form["message"] - loan = loadLoanInformation(getFullPathOfLoanFile(loanFile)) + loan = loadLoanInformation(document_id) amortizeLoan(loan) reportCreated = False @@ -172,7 +156,7 @@ def send_statement(): sendEmail(msg, emailParameters["from_address"], emailParameters["to_address"], emailParameters['password']) - return render_template('email.html', filename=loanFile) + return render_template('email.html', document_id=document_id) ###### @@ -181,37 +165,27 @@ def send_statement(): def getLoanFiles(directory): + #iterate over each of the documents found in the mortgage couchdb + #database and pull their display name loans = [] - directory = os.path.normpath(directory) - print("Directory {}".format(directory)) - fileNames = os.listdir(directory) - fileNames.sort() - for filename in fileNames: - if filename.endswith(".loan"): - displayName = filename.removesuffix(".loan").replace("_"," ") - loans.append(createLoanEntryMenuItem("{0}".format(displayName), filename)) + for document_id in database: + document = database[document_id] + displayName = document['displayName'] + loans.append(createLoanEntryMenuItem(displayName, document_id)) return loans -def createLoanEntryMenuItem(loanName, fileName): +def createLoanEntryMenuItem(loanName, document_id): x = {} x['name'] = loanName - x['filename'] = fileName + x['document_id'] = document_id return x -def getFullPathOfLoanFile(filename): - app_path = os.path.dirname(__file__) - file_path = os.path.normpath(os.path.join(os.path.dirname(__file__),'..')) - print("App Path: {0}\nFile Path: {1}".format(app_path, file_path)) - return os.path.join(file_path, filename) - - ###### # Datastore Manipulation Functions ###### - def getStatementHeader(datastore): return datastore['header'] @@ -220,8 +194,8 @@ def getEmailInformation(datastore): return datastore['email'] -def loadLoanInformation(filename): - datastore = getDatastore(filename) +def loadLoanInformation(document_id): + datastore = getDatastore(document_id) loanModel = {} loanModel['datastore'] = datastore @@ -273,18 +247,11 @@ def getBorrower(datastore): return datastore['borrower'] -def getDatastore(filename=None): - try: - if filename: - with open(filename, 'r') as f: - datastore = json.load(f) - - except Exception as e: - print("An error occurred opening your loan file '%s'. " % filename) - print("The Exception:") - print(e.__repr__()) - quit() +def getDatastore(document_id=None): + if document_id == None: + quit("Invalid document.") + datastore = database[document_id] return datastore ###### @@ -479,7 +446,6 @@ def generatePaymentNotificationEmail(from_address, to_address, subject, html): msg['From'] = from_address msg['To'] = to_address - #msg.attach(MIMEText(body)) part = MIMEBase("text", "html") part.set_payload(html) encoders.encode_base64(part)
    Record an Extra Payment
    Payment Date: