home · contact · privacy
Add relative surplus display.
authorChristian Heller <c.heller@plomlompom.de>
Sun, 5 Mar 2023 19:25:47 +0000 (20:25 +0100)
committerChristian Heller <c.heller@plomlompom.de>
Sun, 5 Mar 2023 19:25:47 +0000 (20:25 +0100)
income_progress_bars.py

index 8a85a4c5a7402ff791a47a033678f1f6c352d1f7..5a4f5ad013eae7e8bbc68b301e1d429c78e23b72 100644 (file)
@@ -25,6 +25,9 @@ td, th {
   background-color: black;
   border: none;
 }
+.surplusbar {
+  width: 200px;
+}
 .time_progress {
   position: absolute;
   height: 20px;
@@ -212,7 +215,9 @@ class MyServer(BaseHTTPRequestHandler):
             success_income_cut = min(success_income, 1.0) 
             success_income_bonus = max(success_income - 1.0, 0) 
             success = success_income + 0
-            diff_goal = earned - goal 
+            diff_goal = "%.2f€" % (earned - goal)
+            if title != "workday":
+                diff_goal += "(%.2f€)" % (earned - (goal * time_progress))
             if time_progress >= 0:
                 success = 1
                 if time_progress > 0:
@@ -221,7 +226,7 @@ class MyServer(BaseHTTPRequestHandler):
             return "<tr><th>%s</th>" \
                     "<td class=\"countable\">%.2f€</td>" \
                     "<td class=\"progressbar\">%s<div class=\"progress\" style=\"background-color: %s; width: %s\"></div></td>" \
-                    "<td class=\"progressbar\"><div class=\"diff_goal\">%.2f€</div><div class=\"progress surplus\" style=\"width: %s\"></div></td></tr>" % (
+                    "<td class=\"progressbar surplusbar\"><div class=\"diff_goal\">%s</div><div class=\"progress surplus\" style=\"width: %s\"></div></td></tr>" % (
                     title, earned, time_progress_indicator, success_color(success), int(success_income_cut * 100), diff_goal, int(success_income_bonus * 100))
         day_income = (db["workday_minutes_worked_1"] / 60.0) * db["workday_hourly_rate_1"] 
         day_income += (db["workday_minutes_worked_2"] / 60.0) * db["workday_hourly_rate_2"]