Added functionality to avoid catching people who are missing first aid in the first 3 years of a role.

This commit is contained in:
Stuart Griffiths 2023-05-30 17:38:23 +01:00
parent 0407bd69e4
commit a47094f4e9
1 changed files with 14 additions and 6 deletions

View File

@ -4,8 +4,8 @@
#Licence: GPL-3.0-or-later
#Written by Stuart Griffiths, stuart.griffiths@birminghamscouts.org.uk
#Started 19/05/2022
#Version:0.6
#Released: 02/10/2022
#Version:0.7
#Released: 30/05/2023
#Status: Working - outputs to 2 seperate CSV files
#Inputs: CSV
#Outputs: multiple CSV and 1 x text file
@ -165,7 +165,6 @@ def training_report():
multi_role = False
if next_line_membership != current_line_membership:
#3.1 acquire dates
#Get today's date
today1 = str(datetime.date.today())
today = datetime.datetime.strptime(today1, "%Y-%m-%d") #dodgy work around comparing datetime to date object error
#Establish comparative date - set by variable
@ -321,9 +320,16 @@ def training_report():
#3.3.3 First Aid
#Read the column
firstaid = input_data[line_num][40]
#Check if in first 3 years of role
three_years_later = role_start + relativedelta(months=+36)
#compare to today
if today < three_years_later:
first_3years = True
else:
first_3years = False
#Check is it late?
#If date is blank, add to list using membership no, known_name, surname, email, telephone, member_role, manager, group, district, safety due, safeguarding due, first aid due
if firstaid == "" and role_training == True and firstaid_required == True and newbie == False:
#If date is blank, not in first 3 years and first aid is required, add to list using membership no, known_name, surname, email, telephone, member_role, manager, group, district, safety due, safeguarding due, first aid due
if firstaid == "" and role_training == True and firstaid_required == True and newbie == False and first_3years == False:
firstaid_status = True
member_number = input_data[line_num][0]
#check whether membership number is in the index and add it if not
@ -450,8 +456,10 @@ def training_report():
if input_data[line_num][41] != "":
#Convert string to date object, has to be done here for the blanks!
firstaid = datetime.datetime.strptime(input_data[line_num][41], "%d/%m/%Y")
#Check if in first 3 years of role
three_years_later = role_start + relativedelta(months=+36)
#If date is less than 6 months from when program is ran, add to list using known_name, surname, email, member_role, group, district, training module
if firstaid < Xmonths_later and firstaid >= today:
if firstaid < Xmonths_later and firstaid >= today and today >= three_years_later:
firstaid_due_status = True
member_number = input_data[line_num][0]
#check whether membership number is in the index and add it if not