Starting the process of migrating to a Docker container.
This commit is contained in:
8
Dockerfile
Normal file
8
Dockerfile
Normal file
@@ -0,0 +1,8 @@
|
||||
FROM python:3.8-slim-buster
|
||||
|
||||
COPY requirements.txt requirements.txt
|
||||
RUN pip3 install -r requirements.txt
|
||||
|
||||
COPY . .
|
||||
|
||||
CMD [ "python3", "-m" , "flask", "run", "--host=0.0.0.0"]
|
||||
@@ -5,7 +5,7 @@ import os
|
||||
from flask import Flask, render_template, request, redirect
|
||||
from decimal import *
|
||||
from datetime import *
|
||||
from fpdf import FPDF, HTML2FPDF, HTMLMixin
|
||||
from fpdf import FPDF, HTMLMixin
|
||||
from email.mime.multipart import MIMEMultipart
|
||||
from email.mime.text import MIMEText
|
||||
from email.mime.base import MIMEBase
|
||||
@@ -32,7 +32,7 @@ def hello():
|
||||
else:
|
||||
return redirect('/?loan=' + loans[0]['filename'])
|
||||
|
||||
loan = loadLoanInformation(getFullPathofLoanFile(filename))
|
||||
loan = loadLoanInformation(getFullPathOfLoanFile(filename))
|
||||
amortizeLoan(loan)
|
||||
|
||||
return render_template('main.html', filename=filename, loans=loans, model=loan)
|
||||
@@ -43,7 +43,7 @@ def update_file():
|
||||
messages = []
|
||||
|
||||
loanFile = request.form["loan"]
|
||||
data = getDatastore(getFullPathofLoanFile(loanFile))
|
||||
data = getDatastore(getFullPathOfLoanFile(loanFile))
|
||||
|
||||
late_fee = Decimal('0.00').quantize(Decimal('1.00'))
|
||||
extra_payment = False
|
||||
@@ -90,7 +90,7 @@ def update_file():
|
||||
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+')
|
||||
backup_file = open(getFullPathOfLoanFile(backup_filename), 'w+')
|
||||
json.dump(data, backup_file, indent=2)
|
||||
backup_file.close()
|
||||
except:
|
||||
@@ -102,7 +102,7 @@ def update_file():
|
||||
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+')
|
||||
file = open(getFullPathOfLoanFile(loanFile), 'w+')
|
||||
json.dump(data, file, indent=2)
|
||||
file.close()
|
||||
except:
|
||||
@@ -144,7 +144,7 @@ def send_statement():
|
||||
subject = request.form["subject"]
|
||||
message = request.form["message"]
|
||||
|
||||
loan = loadLoanInformation(getFullPathofLoanFile(loanFile))
|
||||
loan = loadLoanInformation(getFullPathOfLoanFile(loanFile))
|
||||
amortizeLoan(loan)
|
||||
|
||||
reportCreated = False
|
||||
@@ -182,7 +182,6 @@ def send_statement():
|
||||
|
||||
def getLoanFiles(directory):
|
||||
loans = []
|
||||
count = 0
|
||||
|
||||
directory = os.path.normpath(directory)
|
||||
print("Directory {}".format(directory))
|
||||
@@ -193,26 +192,15 @@ def getLoanFiles(directory):
|
||||
displayName = filename.removesuffix(".loan").replace("_"," ")
|
||||
loans.append(createLoanEntryMenuItem("{0}".format(displayName), filename))
|
||||
|
||||
#loans.append(createLoanEntryMenuItem("1 Brenda Mortgage", "brendamortgage.json"))
|
||||
#loans.append(createLoanEntryMenuItem("2 Dad Mortgage", "Dad-Mortgage.loan"))
|
||||
#loans.append(createLoanEntryMenuItem("3 839 Harbor Bend Loan 1", "HarborBend839-2022.json"))
|
||||
#loans.append(createLoanEntryMenuItem("--ARCHIVE-- Bear Houses LLC Loan", "9Kloan.loan"))
|
||||
#loans.append(createLoanEntryMenuItem("--ARCHIVE-- Test Loan", "testloan.json"))
|
||||
#loans.append(createLoanEntryMenuItem("--ARCHIVE-- Greenfield Lane Mortgage", "greenfield_mortgage.json"))
|
||||
#loans.append(createLoanEntryMenuItem("--ARCHIVE-- Greenfield Lane Refinance", "greenfield_refinance.json"))
|
||||
#loans.append(createLoanEntryMenuItem("--ARCHIVE-- Harbor Bend Loan 1", "BearHousesLLC-22-0001.json"))
|
||||
#loans.append(createLoanEntryMenuItem("--ARCHIVE-- Wayneland Dr D11 Mortgage", "wayneland_mortgage.json"))
|
||||
return loans
|
||||
|
||||
|
||||
def createLoanEntryMenuItem(loanName, fileName):
|
||||
x = {}
|
||||
x['name'] = loanName
|
||||
x['filename'] = fileName
|
||||
return x
|
||||
|
||||
|
||||
def getFullPathofLoanFile(filename):
|
||||
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))
|
||||
@@ -394,7 +382,7 @@ def amortizeLoan(loan):
|
||||
|
||||
loan["total_interest_paid_to_date"] = total_interest
|
||||
|
||||
if (remaining_principal < monthly_payment):
|
||||
if remaining_principal < monthly_payment:
|
||||
loan["parameters"]["next_payment_amt"] = remaining_principal
|
||||
else:
|
||||
loan["parameters"]["next_payment_amt"] = monthly_payment
|
||||
@@ -526,17 +514,17 @@ def createPDF(report):
|
||||
return pdf.output(dest='S')
|
||||
|
||||
|
||||
def selectTemplate(format):
|
||||
if format == 'paymentNotification':
|
||||
def selectTemplate(formatType):
|
||||
if formatType == 'paymentNotification':
|
||||
return 'payment_received_email.html.jinja'
|
||||
|
||||
if format == 'html':
|
||||
if formatType == 'html':
|
||||
return 'statement.html.jinja'
|
||||
|
||||
if format == 'pdf':
|
||||
if formatType == 'pdf':
|
||||
return 'statement.pdf.jinja'
|
||||
|
||||
if format == 'text':
|
||||
if formatType == 'text':
|
||||
return 'statement.text.jinja'
|
||||
|
||||
return 'statement.html.jinja'
|
||||
|
||||
Reference in New Issue
Block a user