Skip to content

Commit

Permalink
Add home loan target payment date, formatting, run script
Browse files Browse the repository at this point in the history
  • Loading branch information
spudooli committed Sep 16, 2022
1 parent f41af40 commit 0361d99
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 50 deletions.
24 changes: 11 additions & 13 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import socket
import paho.mqtt.client as paho
import redis
from dateutil.relativedelta import relativedelta


app = Flask(__name__)

Expand Down Expand Up @@ -134,7 +136,7 @@ def the100x60weeks():
averageperweektogo = int(averageperweektogo) / weeks
averageperweektogo = str(averageperweektogo)
totalsavings = int(r.get('totalsavings'))
html = "Average required per week: $" + averageperweektogo.split(".")[0] + "<br /> <br />Total Retirement Savings: $" + "{:,}".format(totalsavings)
html = "Average required per week: <strong>$" + averageperweektogo.split(".")[0] + "</strong><br /> <br />Total Retirement Savings: <strong>$" + "{:,}".format(totalsavings) + "</strong>"
return html

@app.route("/rainradar")
Expand Down Expand Up @@ -177,18 +179,20 @@ def simplicity():
simplicityGabba = r.get("simplicityGabba")
homeloanbalance = r.get('homeloanbalance')
punakaikicurrentvalue = "9513"
homeloanmonths = homeloanbalance.split(".")[0].replace("-$", "").replace(",", "")
homeloanmonths = int(homeloanmonths) / 4000
homeloanTarget= date.today() + relativedelta(months=+int(homeloanmonths))
print(homeloanmonths)
print(homeloanTarget.strftime("%b %Y"))

html = "<strong>Home Loan:</strong> " + homeloanbalance + "<br><br><strong>Kiwisaver Dave:</strong> " + simplicityDave + "<br><strong>Kiwisaver Gabba:</strong> " + simplicityGabba + "<br><strong>Punakaiki:</strong> $" + "9,513"
html = "Home Loan:<strong> " + homeloanbalance + "</strong><br>Target end date: <strong>" + homeloanTarget.strftime("%b %Y") + "</strong><br><br>Kiwisaver Dave:<strong> " + simplicityDave + "<br></strong>Kiwisaver Gabba:<strong> " + simplicityGabba + "<br></strong>Punakaiki:<strong> $" + "9,513</strong>"

# Calculate the100x60project balance here only because I have most of the values needed already
sharesiesbalance = int(r.get('sharesies'))
# harmoneystring = r.get('harmoney')
# harmoneystring = harmoneystring.split(":")[1].replace(",", "").replace("$", "")
# harmoneystring = harmoneystring.split(".")[0]
simplicityDave = simplicityDave.replace(",", "").replace("$", "")
simplicityGabba = simplicityGabba.replace(",", "").replace("$", "")
totalsavings = int(simplicityDave) + int(simplicityGabba) + int(punakaikicurrentvalue) + int(sharesiesbalance)
#networth = int(totalsavings) + int(1200000) - int(homeloanbalance)
#networth = int(totalsavings) + int(1000000) - int(homeloanbalance)
the100x60projectbalance = int(punakaikicurrentvalue) + int(sharesiesbalance)

broker = "192.168.1.2"
Expand All @@ -214,7 +218,7 @@ def sharesies():
yesterdaysbalance = cursor.fetchone()
change = sharesiesbalance - yesterdaysbalance[1]
cursor.close()
html = "<strong>Sharesies:</strong> $" + str("{:,}".format(sharesiesbalance)) + "</br> Change today: $" + str(change).split(".")[0]
html = "Sharesies:<strong> $" + str("{:,}".format(sharesiesbalance)) + "</strong></br> Change today: $" + str(change).split(".")[0]
return html

@app.route("/websitecomments")
Expand All @@ -234,12 +238,6 @@ def websitecomments():
return html


@app.route("/harmoney")
def harmoney():
harmoneystring = r.get("harmoney")
html = "<strong>Harmoney:</strong> " + harmoneystring.split(":")[1] + " at " + harmoneystring.split(":")[2] + " </br> Funds available: " + harmoneystring.split(":")[0].split(".")[0]
return html

@app.route("/gardenlights")
def gardenlights():
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
Expand Down
8 changes: 4 additions & 4 deletions deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@

echo "Copying the app..."

cp -p /home/dave/Sites/house-dashboard/app.py /var/www/dashboard.spudooli.com/
cp -p /home/dave/Sites/dashboard/app.py /var/www/dashboard.spudooli.com/


echo "Deploying the static assets..."

cp -p /home/dave/Sites/house-dashboard/static/* /var/www/dashboard.spudooli.com/static/
cp -p /home/dave/Sites/house-dashboard/config.py /var/www/dashboard.spudooli.com/config.py
cp -p /home/dave/Sites/dashboard/static/* /var/www/dashboard.spudooli.com/static/
cp -p /home/dave/Sites/dashboard/config.py /var/www/dashboard.spudooli.com/config.py

echo "Deploying the templates..."
cp -p /home/dave/Sites/house-dashboard/templates/* /var/www/dashboard.spudooli.com/templates/*
cp -p /home/dave/Sites/dashboard/templates/* /var/www/dashboard.spudooli.com/templates/*

echo "Clearing the production cache..."
rm -rf /var/www/dashboard.spudooli.com/__pycache__
Expand Down
4 changes: 1 addition & 3 deletions flaskrun.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
export FLASK_ENV=development
export FLASK_APP=app
flask run
flask --app app --debug run
48 changes: 18 additions & 30 deletions templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ <h2>The $100k by 60 Project</h2>
<h2>Things</h2>
<p class='stat_weather' id='simplicity'></p><br>
<p class='stat_weather' id='sharesies'></p><br>
<p class='stat_weather' id='harmoney'></p>
<!-- <div class='audienceBox' id='audienceBox'>
</div> -->
</li>
Expand Down Expand Up @@ -155,17 +154,17 @@ <h2>Show us the bars</h2>
}


function gardenlights() {
$.get('gardenlights', function (data) {
$('#gardenlights').html(data);
});
}
// function gardenlights() {
// $.get('gardenlights', function (data) {
// $('#gardenlights').html(data);
// });
// }

function verandahlights() {
$.get('verandahlights', function (data) {
$('#verandahlights').html(data);
});
}
// function verandahlights() {
// $.get('verandahlights', function (data) {
// $('#verandahlights').html(data);
// });
// }

function osmc() {
$.get('osmc', function (data) {
Expand All @@ -191,12 +190,6 @@ <h2>Show us the bars</h2>
});
}

function harmoney() {
$.get('harmoney', function (data) {
$('#harmoney').html(data);
});
}

function the100x60project() {
$.get('the100x60project', function (data) {
$('#the100x60project').text(data);
Expand Down Expand Up @@ -345,9 +338,9 @@ <h2>Show us the bars</h2>
setInterval(simplicity, 900000);
});

$(document).ready(function () {
setInterval(gardenlights, 300000);
});
// $(document).ready(function () {
// setInterval(gardenlights, 300000);
// });

$(document).ready(function () {
setInterval(gardenshed, 300000);
Expand All @@ -361,9 +354,9 @@ <h2>Show us the bars</h2>
setInterval(websitecomments, 60000);
});

$(document).ready(function () {
setInterval(verandahlights, 300000);
});
// $(document).ready(function () {
// setInterval(verandahlights, 300000);
// });

$(document).ready(function () {
setInterval(osmc, 300000);
Expand All @@ -381,10 +374,6 @@ <h2>Show us the bars</h2>
setInterval(the100x60weeks, 900000);
});

$(document).ready(function () {
setInterval(harmoney, 900000);
});

$(document).ready(function () {
setInterval(outsidehighslows, 600000);
});
Expand Down Expand Up @@ -436,19 +425,18 @@ <h2>Show us the bars</h2>
bankbalancehistory();
simplicity();
sharesies();
harmoney();
gettime();
getdate();
rainradar();
isobars();
bankbalance()
the100x60project();
the100x60weeks();
gardenlights();
// gardenlights();
gardenshed();
spapooltemperature();
websitecomments();
verandahlights();
// verandahlights();
osmc();
}

Expand Down

0 comments on commit 0361d99

Please sign in to comment.