aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSan Jacobs2021-12-06 11:32:46 +0100
committerSan Jacobs2021-12-06 11:32:46 +0100
commit563f4b5fa8bb88b10bed19c8833c0e9f8f2ddb2a (patch)
treea7d837928e3a05ceb5fe7ff3afe1062e666395ba
parent48714ca13fe61b0dc56458840bb73eca4f689386 (diff)
downloadsatscalc-563f4b5fa8bb88b10bed19c8833c0e9f8f2ddb2a.tar.gz
satscalc-563f4b5fa8bb88b10bed19c8833c0e9f8f2ddb2a.tar.bz2
satscalc-563f4b5fa8bb88b10bed19c8833c0e9f8f2ddb2a.zip
It's functional now, wow
-rwxr-xr-xsatscalc.py63
1 files changed, 44 insertions, 19 deletions
diff --git a/satscalc.py b/satscalc.py
index 2e71d3f..60a7cf3 100755
--- a/satscalc.py
+++ b/satscalc.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python3
+#!usr/bin/env python3
import datetime
# NOTE: Maybe the whole thing should be re-thought to actually prompt for date.
@@ -23,48 +23,73 @@ print("Hourly rate:", str(hourly_rate))
print("\nTime to add your hours of work.")
-def timeInput(prompt):
+def timeInput(prompt, fulldate=False):
+
+ if fulldate:
+ formatprompt="YY/MM/DD HrMn"
+ strpformat="%y/%m/%d %H%M"
+ else:
+ formatprompt="HrMn"
+ strpformat="%H%M"
+
while True:
- i = input(prompt)
+ print(prompt)
+ print(formatprompt)
+ i = input()
# If empty, return empty string
if i=="": return ""
- elif len(i)==4: break
- print("Wrong format. Try again.")
-
- t = datetime.datetime.strptime(i,"%H%M")
+ try:
+ t = datetime.datetime.strptime(i, strpformat)
+ break
+ except ValueError:
+ print("Wrong format. Try again.")
return t
+def floatify(hour, minutes):
+ # Turns hour and minute into a single float that is easier to do math with
+ return float(hour+(minutes/60.0))
+
+# --- Data gathering loop ---
+
while True:
- calltime = timeInput("Your call time (24-hour format, hhmm. Leave blank to continue.): ")
- # TODO: Detect turnover problems here, because the previous wraptime is still left over from the previous looparound
- # Though you may still need cache the previous two times before you write those hours to the accumulators. We'll see.
+ calltime = timeInput("CALL TIME (24-hour format. Leave blank to continue.)", True)
if calltime == "":
break
- wraptime = timeInput("Your wrap time (24-hour format, hhmm): ")
+ wraptime = timeInput("\nWRAP TIME (24-hour format)")
+
+ # Giving wrap same date as call
+ wraptime = wraptime.replace(year=calltime.year, month=calltime.month, day=calltime.day)
+ # If clock nr at wrap is equal to or lower than call, then a day has passed.
+ if floatify(wraptime.hour, wraptime.minute) <= floatify(calltime.hour, calltime.minute):
+ wraptime += datetime.timedelta(days=1)
- # Make sure we're not traveling backwards in time
- if wraptime < calltime:
- wraptime = wraptime.replace(day=wraptime.day+1)
difference = wraptime-calltime
hours_worked = difference.total_seconds()/3600
- # TODO: This part makes no sense. Don't worry. It'll be made to make sense.
- # TODO: Apparently there is a rule that you always have to invoice for 4 hours or more on ad-shoots. Investigate.
-
- weekend = "y" in input("Was this a weekend? [y/n]: ").lower()
+ print("\nCalltime:",calltime)
+ print("Wraptime:",wraptime)
+ print("Delta:",hours_worked,"hours.\n")
+
+ # This part makes no sense. Don't worry. It'll be made to make sense.
overtime = hours_worked > 8
if overtime:
overtime_hours = hours_worked-8
print("Overtime detected.")
warned_overtime = "y" in input("Was this overtime warned about before 12 o'clock the day before? [y/n]: ").lower()
+ if warned_overtime:
+ if "n" in input("Was it warned of entirely? [y/n] ").lower():
+ #overtime_warned_until = timeInput("Until what time was it warned?")
+ print("Feature not yet implemented.")
+
# --- Price calculation ---
-# Notes:
+# NOTE:
# First two hours of warned overtime are 50%, unwarned is 100%
# Any work after 20:00 is overtime
+# There is a rule that you always have to invoice for 4 hours or more pr day on ad-shoots. Take this into account.
#
# Extremely naive calculation