more pto updates
This commit is contained in:
@@ -1,7 +1,11 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
# PTO Countdown
|
||||||
|
import os
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
|
|
||||||
|
# Clear the terminal screen
|
||||||
|
os.system('cls' if os.name == 'nt' else 'clear')
|
||||||
|
|
||||||
def calculate_reach_date(current_hours, max_hours, hours_added_bi_weekly):
|
def calculate_reach_date(current_hours, max_hours, hours_added_bi_weekly):
|
||||||
"""
|
"""
|
||||||
Calculates the estimated date when the maximum Paid Time Off (PTO) hours will be reached.
|
Calculates the estimated date when the maximum Paid Time Off (PTO) hours will be reached.
|
||||||
@@ -14,49 +18,35 @@ def calculate_reach_date(current_hours, max_hours, hours_added_bi_weekly):
|
|||||||
Returns:
|
Returns:
|
||||||
- datetime.date: The estimated date when the maximum PTO balance is reached.
|
- datetime.date: The estimated date when the maximum PTO balance is reached.
|
||||||
"""
|
"""
|
||||||
# Calculate the additional hours needed to reach the maximum
|
|
||||||
hours_needed = max_hours - current_hours
|
hours_needed = max_hours - current_hours
|
||||||
|
|
||||||
# Determine the number of bi-weekly periods needed to accumulate the necessary hours
|
|
||||||
bi_weekly_periods_needed = hours_needed / hours_added_bi_weekly
|
bi_weekly_periods_needed = hours_needed / hours_added_bi_weekly
|
||||||
|
days_needed = bi_weekly_periods_needed * 14
|
||||||
# Convert the period into days
|
|
||||||
days_needed = bi_weekly_periods_needed * 14 # Two weeks per bi-weekly period
|
|
||||||
|
|
||||||
# Calculate the future date when the maximum will be reached
|
|
||||||
reach_date = datetime.now() + timedelta(days=days_needed)
|
reach_date = datetime.now() + timedelta(days=days_needed)
|
||||||
return reach_date
|
return reach_date
|
||||||
|
|
||||||
# Constants for the program
|
# Constants for the program
|
||||||
MAX_HOURS = 240 # The maximum PTO balance allowed
|
MAX_HOURS = 240
|
||||||
# The standard rate of PTO accrual every two weeks
|
HOURS_ADDED_BI_WEEKLY = 6.15384615 # 160 hours per year
|
||||||
HOURS_ADDED_BI_WEEKLY = 6.15384615
|
# HOURS_ADDED_BI_WEEKLY = 7.69230769 # 200 hours per year
|
||||||
# An alternative accrual rate for different scenarios (commented out by default)
|
# HOURS_ADDED_BI_WEEKLY = 9.61538462 # 250 hours per year
|
||||||
# HOURS_ADDED_BI_WEEKLY = 7.69230769
|
LAST_KNOWN_PTO_BALANCE = 220.08
|
||||||
LAST_KNOWN_PTO_BALANCE = 220.08 # An example of a last known PTO balance
|
|
||||||
|
|
||||||
# Introduction and instructions for the user
|
# Introduction and instructions for the user
|
||||||
print("PTO Balance Calculator")
|
print("PTO Balance Calculator")
|
||||||
print("----------------------")
|
print("----------------------")
|
||||||
print("Determine when you will reach your maximum PTO balance based on your current accrual.")
|
print("Determine when you will reach your maximum PTO balance based on your current accrual.")
|
||||||
|
|
||||||
# Display the last known PTO balance to assist with user input
|
|
||||||
print(f"\nLast known PTO balance: {LAST_KNOWN_PTO_BALANCE}\n")
|
print(f"\nLast known PTO balance: {LAST_KNOWN_PTO_BALANCE}\n")
|
||||||
|
|
||||||
# Handling user input
|
# Handling user input
|
||||||
try:
|
try:
|
||||||
# Prompting the user to enter their current PTO balance
|
|
||||||
current_hours_input = input("Enter your current PTO hours: ")
|
current_hours_input = input("Enter your current PTO hours: ")
|
||||||
current_hours = float(current_hours_input.strip()) # Convert input to a floating-point number
|
current_hours = float(current_hours_input.strip())
|
||||||
|
|
||||||
# Calculation based on user input
|
|
||||||
reach_date = calculate_reach_date(current_hours, MAX_HOURS, HOURS_ADDED_BI_WEEKLY)
|
reach_date = calculate_reach_date(current_hours, MAX_HOURS, HOURS_ADDED_BI_WEEKLY)
|
||||||
|
|
||||||
# Displaying the calculation results
|
|
||||||
print("\nCalculation Results")
|
print("\nCalculation Results")
|
||||||
print("-------------------")
|
print("-------------------")
|
||||||
print(f"Today's Date: {datetime.now().strftime('%A, %B %d, %Y')}")
|
print(f"Today's Date: {datetime.now().strftime('%A, %B %d, %Y')}")
|
||||||
print(f"Maximum PTO balance of {MAX_HOURS} hours will be reached on: {reach_date.strftime('%A, %B %d, %Y')}.")
|
print(f"Maximum PTO balance of {MAX_HOURS} hours will be reached on: {reach_date.strftime('%A, %B %d, %Y')}.")
|
||||||
except ValueError:
|
except ValueError:
|
||||||
# Error handling for non-numeric inputs
|
|
||||||
print("Error: Please enter a valid number for your current PTO hours.")
|
print("Error: Please enter a valid number for your current PTO hours.")
|
||||||
|
|||||||
Reference in New Issue
Block a user